--- layout: post title: "Reproducaible Reporting: Fort Collins Housing" permalink: "FC_housing" ---
City of Fort Collins Open Data Portal
The city of Fort Collins has an open data portal website which allows anyone with an internet connection to view, download, and ask questions of over a 100 different data resources. Many of these datasets are displayed with interactive maps and or charts that all you to filter and ask your own questions of the data. However, the option for filtering and displaying of geospatial data is fairly limited and makes it difficult to get answers to your own questions. We’re going to take steps to reproduce one of these resources, the “New Construction Permits” dataset, that allows a end user to see more visualizations while providing them more tools to filter the non spatial data associate with each location. This data is updated on a regular basis so we using a reproducible methodology to generate this report so that when new content is created we can quickly update our representations of the data.
To create this reproducible methodology were are going to use a RMarkdown Document. R allows use to evaluate and manipulate the data. Markdown allows us to add plain text elements, bring in pictures and hypelinks, and generate a final product in the form of an html. There are some important R libraries we are relying on.
sp : Classes and Methods for Spatial Data docs
A super helpful resource for working with spatial data in R
geojsonio : Convert Data from and to ‘GeoJSON’ or ‘TopoJSON’ docs
tmap : Creating thematic maps docs
A amazing resource for generating maps of various complexity.
DT : A Wrapper of the JavaScript Library ‘DataTables’ docs
Allows you to create interactive html tables with your document.
dplyr : Fast and consistent tool for working with data frame like objects docs
The best thing about R
Ideally we would like to be able to access our data direction from pulling it down from Fort Collins website. This i an option, but I haven’t put in the time to make it work yet. So instead were simply going to download the data as a geojson and read it as a “spatialpointsDataFrame”, a sp class that works well with tmap. So with a download, some time in the docs, and two lines we have a reproduction of the first element of the Fort Collins webpage. An interactive map.
#downloading the data from https://opendata.fcgov.com/Economic-Health/New-Construction-Permits/4nr5-i9u8
cData <- geojson_read(x = paste0(base_dr, "/New Construction Permits.geojson" ), parse = TRUE, what = "sp")
# x = path to file
# parse = determines if the program should try to fit the data to the data frame structure rather then a json structure
# what = Allows you to define the class object the data will be converted to.
qtm(cData)